package com.se.mapper;


import com.se.domain.mysql.ImgDO;
import com.se.domain.qo.ImgQO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ImgMapper {

    void insertAll(@Param("list") List<ImgDO> list);
	
	@Insert("insert into img(path,url,type) " +
			"values (#{path}, #{url}, #{type})")
	@Options(useGeneratedKeys = true, keyProperty = "imgId", keyColumn = "img_id")
	void insertImg(ImgDO imgDO);
	
	@Update("update img set active = false " +
			"where img_id = #{id}")
	void logicDeleteById(@Param("id") Long id);
	
	@Select("select img_id, path, url, type " +
			"from img " +
			"where img_id = #{id}")
	ImgQO getQOById(@Param("id") Long id);
	
	//通过主键查询QO
	@Select("select img_id, path, url, type " +
			"from img " +
			"where img_id = #{id} and active = true")
	ImgQO getActiveQOById(@Param("id") Long id);
	
	void logicDeleteByIdList(
			@Param("list") List<Long> list);
	
	List<ImgQO> listActiveQOByIdList(
			@Param("list") List<Long> list);

	void deleteByIdList(@Param("list") List<Long> imgIdList);
}
